/*
 * @Author: 江舟 jijiangzhou@recycloud.cn
 * @Date: 2024-04-12 10:53:43
 * @LastEditors: 江舟 jijiangzhou@recycloud.cn
 * @LastEditTime: 2024-04-12 10:58:31
 * @FilePath: \vite-project\src\hooks\basicSystem\useGetCarTypeTree.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { getCarTypeTree } from '@/apis/basicSystem/carType';
import { useEffect, useState } from 'react';

export default function useGetCarTypeTree() {
	const [carTreeData, setCarTreeData] = useState<any[]>([]);
	const [carTreeLoading, setCarTreeLoading] = useState(false);
	// 获取时间范围内类型树
	const getTreeData = () => {
		setCarTreeLoading(true);
		getCarTypeTree({
			validStat: 1,
		})
			.then(res => {
				const curTreeData = [
					{
						...(res?.typeTree || {}),
						disabled: true,
					},
				];
				setCarTreeData(curTreeData);
			})
			.finally(() => {
				setCarTreeLoading(false);
			});
	};
	useEffect(() => {
		getTreeData();
	}, []);
	return {
		carTreeData,
		carTreeLoading,
	};
}
